﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnDecrypt_Click(object sender, EventArgs e)
        {

        }

        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            string input = txtInput.Text;
            string output = "";
            foreach (char c in input)
            {
                if (char.IsLetter(c))
                {
                    char baseChar = char.IsUpper(c) ? 'A' : 'a';
                    output += (char)((c - baseChar + 13) % 26 + baseChar);
                }
                else
                {
                    output += c;
                }
            }
            txtInput.Text = output;
        }

        private void btnDecrypt_Click_1(object sender, EventArgs e)
        {
         
            // 复位为加密前的原始文本（可根据实际需求设置初始文本）
            txtInput.Text = "The simple Caesar-cypher encryption that replaces each English letter with the one 13 places forward or back along the alphabet.\nA major advantage of rot13 over rot(N) for other N is that it is self-inverse, so the same code can be used for encoding and decoding.";
        }
    }
    }

